const isDevelopment = process.env.NODE_ENV !== 'production';
const path = require('path')
/**
 * task事件
 */
export const userTasks = [
];

/**
 * 主要禁用
 * - F11 禁用全屏放大
 * - CTRL+R 禁用刷新
 * - CTRL+SHIFT+R 禁用刷新
 */
export const disabledKeys = () => {
  const devShortcuts = ['F11', 'Ctrl+R', 'Ctrl+SHIFT+R'];
  const shortcuts = ['Ctrl+N', 'SHIFT+F10', 'Ctrl+SHIFT+I'];
  const exportKeys = isDevelopment ? shortcuts : [...devShortcuts, ...shortcuts];
  return exportKeys;
};


/**
 * BrowserWindow的配置项
 * @param type 单独给编辑窗口的配置
 */
export const browserWindowOption = () => {
  const devWid = isDevelopment ? 1000 : 0;
  const devHei = isDevelopment ? 700 : 0;

  // 底部icon: 40*40
  const editorWindowOptions = {
    width: devWid || 290,
    height: devHei || 320,
    minWidth: 290
  };
  const commonOptions = {
    frame: false,
    hasShadow: true,
    transparent: true,
    fullscreen: false,
    show: false,
    center: true,
    hasShadow: true,
    icon: path.join(__static, 'logo.png'),
    minHeight: 630,
    webPreferences: {
      enableRemoteModule: true,
      nodeIntegration: true,
      contextIsolation: false,
      webSecurity: false,
      nodeIntegrationInSubFrames: true,
      preload: path.join(__dirname, 'preload.js'),
      allowRunningInsecureContent: true,
    }
  };
  // 兼容mac
  if (process.platform === 'darwin') {
    commonOptions.frame = true;
    commonOptions.transparent = false;
    commonOptions.backgroundColor = '#ffffff';
  }
  return {
    ...editorWindowOptions,
    ...commonOptions
  };
};

/**
 * 开发环境: http://localhost:55225
 *
 * 正式环境: app://${__dirname}/index.html
 */
export const winURL = isDevelopment ? 'http://localhost:55225' : 'app://./index.html';